<template>
  <div class="nie">
    <van-nav-bar
      title="修改昵称"
      left-text="取消"
      right-text="完成"
      left-arrow
      @click-left="$emit('colse')"
      @click-right="wangc"
    />
    <van-field
      class="firles"
      v-model="ziname"
      rows="2"
      autosize
      
      type="textarea"
      maxlength="7"
      placeholder="请输入留言"
      show-word-limit
    />
  </div>
</template>
<script>
import { upUserDate } from "../../api/user"
// console.log(upUserDate)
export default {
    name:'updata',
    props:{
        name:{
            type:String,
            required:true
        }
    },
    created(){
        // // this.sme()
        // this.message = this.name
    },
    data(){
        return {
            ziname:this.name
        }
    },
    methods:{
        async wangc(){
            this.$toast.loading({
                message:'保存中',
                forbidClick:true
            })
            try{
                await upUserDate({
                    name:this.ziname

                })
                this.$toast.success('成功');
                this.$emit('upDataname',this.ziname)
                this.$emit('colse')

            }catch (err){
                if (err && err.response && err.response.status == 409){
                    this.$toast.fail('昵称已存在')

                }

            }
            
        }
        
    }
};
</script>
<style scoped lang="less">
.firles {
    margin-top: 10px;
}
    
</style>